<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('申报系统列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>课题名称：</label>
                                <input type="text" name="projectTitle"/>
                            </li>
                            <li>
                                <label>申报年度：</label>
                                <select name="declareTheAnnual" th:with="type=${@dict.getType('sys_year')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>研究类型：</label>
                                <select name="researchType" th:with="type=${@dict.getType('sys_research_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>负责人：</label>
                                <input type="text" name="principal"/>
                            </li>
                            <li>
                                <label>行政职务：</label>
                                <select name="administrativePost" th:with="type=${@dict.getType('sys_administrativ_service')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>专业职务：</label>
                                <select name="professionalDuties" th:with="type=${@dict.getType('sys_duties')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>最高学历：</label>
                                <select name="officialAcademicCredentials" th:with="type=${@dict.getType('sys_education')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>最高学位：</label>
                                <select name="theHighestDegree" th:with="type=${@dict.getType('sys_degree')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>电子邮箱：</label>
                                <input type="text" name="emailAddress"/>
                            </li>
                            <li>
                                <label>联系电话：</label>
                                <input type="text" name="contactNumber"/>
                            </li>
<!--                            <li>-->
<!--                                <label>第一次审批状态：</label>-->
<!--                                <select name="firstApprovalStatus" th:with="type=${@dict.getType('sys_status')}">-->
<!--                                    <option value="">所有</option>-->
<!--                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
<!--                                </select>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>第二次审批状态：</label>-->
<!--                                <select name="secondApprovalStatus" th:with="type=${@dict.getType('sys_status')}">-->
<!--                                    <option value="">所有</option>-->
<!--                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
<!--                                </select>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>第三次审批状态：</label>-->
<!--                                <select name="thirdApprovalStatus" th:with="type=${@dict.getType('sys_status')}">-->
<!--                                    <option value="">所有</option>-->
<!--                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
<!--                                </select>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>第四次审批状态：</label>-->
<!--                                <select name="fourthApprovalStatus" th:with="type=${@dict.getType('sys_status')}">-->
<!--                                    <option value="">所有</option>-->
<!--                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
<!--                                </select>-->
<!--                            </li>-->
                            <li>
                                <label>上传作者：</label>
                                <input type="text" name="chinappt"/>
                            </li>
<!--                            <li>-->
<!--                                <label>关联id：</label>-->
<!--                                <input type="text" name="userId"/>-->
<!--                            </li>-->
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="ruoyi:declare:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="ruoyi:declare:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="ruoyi:declare:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="ruoyi:declare:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('ruoyi:declare:edit')}]];
        var removeFlag = [[${@permission.hasPermi('ruoyi:declare:remove')}]];
        var declareTheAnnualDatas = [[${@dict.getType('sys_year')}]];
        var researchTypeDatas = [[${@dict.getType('sys_research_type')}]];
        var administrativePostDatas = [[${@dict.getType('sys_administrativ_service')}]];
        var professionalDutiesDatas = [[${@dict.getType('sys_duties')}]];
        var officialAcademicCredentialsDatas = [[${@dict.getType('sys_education')}]];
        var theHighestDegreeDatas = [[${@dict.getType('sys_degree')}]];
        var firstApprovalStatusDatas = [[${@dict.getType('sys_status')}]];
        var secondApprovalStatusDatas = [[${@dict.getType('sys_status')}]];
        var thirdApprovalStatusDatas = [[${@dict.getType('sys_status')}]];
        var fourthApprovalStatusDatas = [[${@dict.getType('sys_status')}]];
        var statusDatas = [[${@dict.getType('sys_status')}]];
        var prefix = ctx + "ruoyi/declare";
        var prefixs = ctx + "ruoyi/information";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "申报系统",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'projectTitle',
                    title: '课题名称'
                },
                {
                    field: 'declareTheAnnual',
                    title: '申报年度',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(declareTheAnnualDatas, value);
                    }
                },
                {
                    field: 'researchType',
                    title: '研究类型',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(researchTypeDatas, value);
                    }
                },
                {
                    field: 'principal',
                    title: '负责人'
                },
                {
                    field: 'administrativePost',
                    title: '行政职务',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(administrativePostDatas, value);
                    }
                },
                {
                    field: 'professionalDuties',
                    title: '专业职务',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(professionalDutiesDatas, value);
                    }
                },
                {
                    field: 'officialAcademicCredentials',
                    title: '最高学历',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(officialAcademicCredentialsDatas, value);
                    }
                },
                {
                    field: 'theHighestDegree',
                    title: '最高学位',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(theHighestDegreeDatas, value);
                    }
                },
                {
                    field: 'emailAddress',
                    title: '电子邮箱'
                },
                {
                    field: 'contactNumber',
                    title: '联系电话'
                },
                {
                    field: 'applicationForm',
                    title: '申请书',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (row.applicationForm==null||row.applicationForm==''){
                            actions.push('<p>未提交</p> ');
                            return actions.join('');
                        }else{
                            actions.push('<a href=\''+row.applicationForm+'\' target="_blank" rel="nofollow">查看文件</a> ');
                            return actions.join('');
                        }
                        return actions.join('');
                    }
                },
                {
                    field: 'leaflet',
                    title: '活页',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (row.leaflet==null||row.leaflet==''){
                            actions.push('<p>未提交</p> ');
                            return actions.join('');
                        }else{
                            actions.push('<a href=\''+row.leaflet+'\' target="_blank" rel="nofollow">查看文件</a> ');
                            return actions.join('');
                        }
                        return actions.join('');
                    }
                },
                // {
                //     field: 'firstApprovalStatus',
                //     title: '第一次审批状态',
                //     formatter: function(value, row, index) {
                //        return $.table.selectDictLabel(firstApprovalStatusDatas, value);
                //     }
                // },
                {
                    field: 'thesisProposal',
                    title: '开题报告',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (row.thesisProposal==null||row.thesisProposal==''){
                            actions.push('<p>未提交</p> ');
                            return actions.join('');
                        }else{
                            actions.push('<a href=\''+row.thesisProposal+'\' target="_blank" rel="nofollow">查看文件</a> ');
                            return actions.join('');
                        }
                        return actions.join('');
                    }
                },
                // {
                //     field: 'secondApprovalStatus',
                //     title: '第二次审批状态',
                //     formatter: function(value, row, index) {
                //        return $.table.selectDictLabel(secondApprovalStatusDatas, value);
                //     }
                // },
                {
                    field: 'interimReport',
                    title: '中期报告',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (row.interimReport==null||row.interimReport==''){
                            actions.push('<p>未提交</p> ');
                            return actions.join('');
                        }else{
                            actions.push('<a href=\''+row.interimReport+'\' target="_blank" rel="nofollow">查看文件</a> ');
                            return actions.join('');
                        }
                        return actions.join('');
                    }
                },
                // {
                //     field: 'thirdApprovalStatus',
                //     title: '第三次审批状态',
                //     formatter: function(value, row, index) {
                //        return $.table.selectDictLabel(thirdApprovalStatusDatas, value);
                //     }
                // },
                {
                    field: 'closingReport',
                    title: '结题报告',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (row.closingReport==null||row.closingReport==''){
                            actions.push('<p>未提交</p> ');
                            return actions.join('');
                        }else{
                            actions.push('<a href=\''+row.closingReport+'\' target="_blank" rel="nofollow">查看文件</a> ');
                            return actions.join('');
                        }
                        return actions.join('');
                    }
                },
                {
                    field: 'applicationForAlteration',
                    title: '变更申请书',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (row.applicationForAlteration==null||row.applicationForAlteration==''){
                            actions.push('<p>未提交</p> ');
                            return actions.join('');
                        }else{
                            actions.push('<a href=\''+row.applicationForAlteration+'\' target="_blank" rel="nofollow">查看文件</a> ');
                            return actions.join('');
                        }
                        return actions.join('');
                    }
                },
                {
                    field: 'firstApprovalStatus',
                    title: '审批状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field: 'chinappt',
                    title: '上传作者',
                    sortable: true,
                    formatter: function(value, row, index) {
                        return '<a href="javascript:void(0)" onclick="toViewTheAuthor(\'' + row.userId + '\')">' + value + '</a>';
                    }
                },
                // {
                //     field: 'userId',
                //     title: '关联id'
                // },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.firstApprovalStatus===0){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="tijiao(\'' + row.id + '\')"><i class="fa fa-edit"></i>提交</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }else if(row.firstApprovalStatus===6){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="tijiao(\'' + row.id + '\')"><i class="fa fa-edit"></i>重新提交</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }else if(row.firstApprovalStatus===5){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="submitTheProposalReport(\'' + row.id + '\')"><i class="fa fa-edit"></i>提交开题报告</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="uploadTheOpeningReport(\'' + row.id + '\')"><i class="fa fa-edit"></i>上传开题报告</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }else if(row.firstApprovalStatus===8){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="submissionOfInterimReport(\'' + row.id + '\')"><i class="fa fa-edit"></i>提交中期报告</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="uploadInterimReport(\'' + row.id + '\')"><i class="fa fa-edit"></i>上传中期报告</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }else if(row.firstApprovalStatus===9){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="submitTheProposalReport(\'' + row.id + '\')"><i class="fa fa-edit"></i>重新提交开题报告</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="uploadTheOpeningReport(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑开题报告</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }else if (row.firstApprovalStatus===11){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="submitTheFinalReport(\'' + row.id + '\')"><i class="fa fa-edit"></i>提交结题报告</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="uploadTheFinalReport(\'' + row.id + '\')"><i class="fa fa-edit"></i>上传结题报告</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }else if (row.firstApprovalStatus===12){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="submissionOfInterimReport(\'' + row.id + '\')"><i class="fa fa-edit"></i>重新提交中期报告</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="uploadInterimReport(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑中期报告</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }else if (row.firstApprovalStatus===15){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="submitTheFinalReport(\'' + row.id + '\')"><i class="fa fa-edit"></i>重新提交结题报告</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="uploadTheFinalReport(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑结题报告</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }
                        actions.push('<a class="btn btn-default btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="participant(\'' + row.id + '\')"><i class="fa fa-edit"></i>添加参与人员</a>');
                        actions.push('<a class="btn btn-default btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="selectParticipant(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看参与人员</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        //查看作者
        function toViewTheAuthor(userId) {
            var url = prefix + '/toViewTheAuthor/' + userId;
            $.modal.openTab("查看详情", url);
        }
        //上传结题报告
        function uploadTheFinalReport(id) {
            var urls= prefix+"/uploadTheFinalReport/"+id;
            $.modal.open("编辑",urls);
        }
        //提交结题报告
        function submitTheFinalReport(id) {
            $.modal.confirm("确认要提交申请吗?", function() {
                var url = prefix + "/submitTheFinalReport";
                var data = { "id": id };
                $.operate.submit(url, "post", "json", data);
            });
        }
        //提交中期报告
        function submissionOfInterimReport(id) {
            $.modal.confirm("确认要提交申请吗?", function() {
                var url = prefix + "/submissionOfInterimReport";
                var data = { "id": id };
                $.operate.submit(url, "post", "json", data);
            });
        }
        //上传中期报告
        function uploadInterimReport(id) {
            var urls= prefix+"/uploadInterimReport/"+id;
            $.modal.open("编辑",urls);
        }

        //上传开题报告
        function uploadTheOpeningReport(id) {
            var urls= prefix+"/uploadTheOpeningReport/"+id;
            $.modal.open("编辑",urls);
        }
        //提交开题报告
        function submitTheProposalReport(id) {
            $.modal.confirm("确认要提交申请吗?", function() {
                var url = prefix + "/submitTheProposalReport";
                var data = { "id": id };
                $.operate.submit(url, "post", "json", data);
            });
        }

        //第一次提交
        function tijiao(id) {
            $.modal.confirm("确认要提交申请吗?", function() {
                var url = prefix + "/tijiao";
                var data = { "id": id };
                $.operate.submit(url, "post", "json", data);
            });
        }
        //添加其他参与人员
        function participant(userId) {
            var url = prefixs + '/participant/' + userId;
            $.modal.openTab("添加参与人员", url);
        }
        //查看其他参与人员
        function selectParticipant(userId) {
            var url = prefixs +  '/selectInformation/'+ userId;
            $.modal.open("查看参与人员", url);
        }
    </script>


</body>
</html>